package cn.edu.fzu.homemaking.service.impl;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import cn.edu.fzu.homemaking.exception.ServiceException;
import cn.edu.fzu.homemaking.helper.UploadHelper;
import cn.edu.fzu.homemaking.service.SysFaceService;

/**
 * @author yifan
 * @date 2023/4/10
 */
@Service
public class SysFaceServiceImpl implements SysFaceService {

    @Value("${file-url}")
    private String fileUrl;


    @Override
    public String uploadFace(MultipartFile face) {
        if (face == null) {
            throw new ServiceException("请上传人脸照片");
        }
        try {
            return UploadHelper.upload(String.valueOf(System.currentTimeMillis()), face, fileUrl);
        } catch (IOException e) {
            throw new ServiceException("系统异常，请稍候重试");
        }
    }
}
